%macro get_ppp;

	proc printto new log = "&logdir./get_ppp.txt";
	run;
	
	proc sql;
		[redacted] (
				select 
					sum(a.[redacted]) as ppp_amount,
					(substr(a.[redacted],7,4)) as year,
					(substr(a.[redacted],1,2)) as month,
					c.[redacted] as firm_id
				from [redacted] as a
					inner join [redacted] as b
						on(a.[redacted] = b.[redacted])
					inner join [redacted] as c
						on(b.[redacted] = c.[redacted])
				where b.[redacted] >= 0.8
				group by c.[redacted], year, month
				order by c.[redacted], year, month
			
						
			
		);
	disconnect from iq;
	quit;

	data ppp;
		set ppp;
		ppp_first_ym = cats(year,month);
	run;
	
	proc sort data = ppp;
		by firm_id ppp_first_ym;
	run;
	data rlib.ppp;
		set ppp;
		by firm_id;
		if first.firm_id;
		keep firm_id ppp_first_ym;
	run;
		
	
	
	
	proc printto;
	run;


%mend;

